<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.ResultSet"%>
<%
	String DRV = "org.mariadb.jdbc.Driver";
	String URL = "jdbc:mariadb://localhost:3306/jwj8508?user=jwj8508&password=123456";
	String sql = "select bdno, title, uid, wdate, reades from boardv4 order by bdno desc";
	
	Connection conn = null;
	PreparedStatement pstmt = null;
	ResultSet rs = null;
%>
<!DOCTYPE html>
<html lang="ko">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<title>JSP 프로젝트 v1</title>
		<link type="text/css" href="../css/layout.css" rel="stylesheet" />
		<style type="text/css">				
			table {
				width: 70%;
				margin: 0 auto;
				border-collapse: collapse;
				table-layout: fixed;
			}
			th,td {
				border: 1px solid black;
				padding: 10px;
				text-align: center;
			}
			.bdtitle {
				text-align: left;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
			}
			.cpage {
				font-size: 2em;
				font-weight: bold;
				color: red;
			}
			.center {
				text-align: center;
			}			
		</style>
		
	</head>
	<body>
		<div>
			<h1>JSP 프로젝트 v1</h1> <!-- 제목 -->
			<ul id="nav">
				<li><a href="../index.html">Home</a></li>
				<li><a href="../member/join.html">회원가입</a></li>
				<li><a href="../member/login.html">로그인</a></li>
				<li><a href="list.html">게시판</a></li>
				<li><a href="../member/myinfo.html">회원정보</a></li>
			</ul> <!-- 상단메뉴 -->
			<hr />
		</div> <!-- header -->
		
		<div id="content">
			<h2>게시판</h2>			
			<table>
				<colgroup>
					<col style="width: 10%" />
					<col />
					<col style="width: 15%" />
					<col style="width: 15%" />
					<col style="width: 10%" />
				</colgroup>
				<!-- 제목행 시작 -->
				<tr><th>번호</th><th>제목</th><th>작성자</th><th>작성일</th><th>조회</th></tr>
				<!-- 제목행 끝 -->
				<%
					try {
						Class.forName(DRV);
						conn = DriverManager.getConnection(URL);
						pstmt = conn.prepareStatement(sql);
						rs = pstmt.executeQuery();
						
						if(rs.next()){
							do {
				%>				
				<!-- 본문행 출력 시작 -->
				<tr>
					<td><%=rs.getString("bdno") %></td>
					<td class="bdtitle">
						<a href="view.jsp?bdno=<%=rs.getString("bdno") %>">
							<%=rs.getString("title") %>
						</a>
					</td>
					<td><%=rs.getString("uid") %></td>
					<td><%=rs.getString("wdate").substring(0, 10) %></td>
					<td><%=rs.getString("reades") %></td>
				</tr>
				<!-- 본문행 출력 끝 -->
				<%
							} while(rs.next());
						}	// if
						
					} catch (Exception e) {
						e.printStackTrace();
					} finally {
						if (rs!=null)try{rs.close();}catch(Exception e){}
						if (pstmt!=null)try{pstmt.close();}catch(Exception e){}
						if (conn!=null)try{conn.close();}catch(Exception e){}
					}	
				%>
			<tr><td colspan="5" style="border: none; text-align: right;">
				<button type="button" onclick="location.href='write.html';">글쓰기</button></td>
			</tr>
			</table>
			<p class="center">◀  ◁◁ <span class="cpage">1</span> 2 3 4 5 6 7 8 9 ▷▷ ▶</p>
		</div> <!-- content -->
		
		<div>
			<hr />
			<p id="copy">Copyright &copy; 2013 JINn. All right reserved.</p>
		</div> <!-- footer -->
		
		
	</body>
</html>
